<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="/typeUtil"  prefix="typeUtil"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
	<label>订单状态:${condi }</label><br>
	<label>订单id:${orderId }</label><br>
	<input type='hidden' id='orderId' value='${orderId }'>
	<input type='hidden' id='password' value='${password }'>
	<label>入住日期:${inDate }</label><br>
	<label>离店日期:${outDate }</label><br>
	<label>操作密码:${password }</label><br>
	<label>房型：${typeUtil:getTypeName(room.typeId)}</label><br>
	<label>房间名称：${room.name}</label><br>
	<label>楼层：${room.floor }</label><br>
	<label>联系电话:${phone}</label><br>
	<img id="img1" src="/hotel/upload/${room.pic }" width="100" height="100"/><br>
	<label>总金额:${price }</label><br>
	<c:if test="${condi==0}">
		<button id="pay">确认付款</button> &nbsp;&nbsp;&nbsp;
		<button id="cancel">取消订单</button>
	</c:if> 
	<c:if test="${condi==1}">
		<button id="refund">请求退款</button>
	</c:if>
	
</body>
<script type="text/javascript" src="/hotel/js/jquery.min.js"></script>
<script type="text/javascript">
<c:if test="${condi==0}">
	$("#cancel").click(function(){
		if(!confirm('您确定要取消订单吗'))
			return 
		$.post("/hotel/reserve/cancelRoom",{id:$('#orderId').val(),'password':$('#password').val()},function(str){
			var res=eval('(' +str + ')')
			if(res.code!=0){
				alert(res.message)
				return;
			}else{
				res=res.object
				window.location.href="/hotel/visitor/roomList"
			}
		})
	})
		$('#pay').click(function(){
			if(!confirm('您确定要付款吗'))
				return 
			$.post("/hotel/reserve/payReserve",{id:$('#orderId').val()},function(str){
				var res=eval('(' +str + ')')
				if(res.code!=0){
					alert(res.message)
					return;
				}else{
					res=res.object
					window.location.href="/hotel/reserve/getReserve?id="+$('#orderId').val()
				}
			})
		})
</c:if>
<c:if test="${condi==1}">
	$('#refund').click(function(){
	if(!confirm('您确定要发起退款吗'))
		return 
	$.post("/hotel/reserve/cancelReserve",{'id':$('#orderId').val(),'password':$('#password').val()},function(str){
		var res=eval('(' +str + ')')
		if(res.code!=0){
			alert(res.message)
			return;
		}else{
			res=res.object
			window.location.href="/hotel/reserve/getReserve?id="+$('#orderId').val()
		}
	})
})
</c:if>
</script>
</html>